to-number-x
Converts argument to a value of type Number.
module.exports(value)
⇒ *
⏏
to-number-x
⇒ *
This method converts argument to a value of type Number. (ES2019)
Kind: static property of to-number-x
Returns: *
- The argument converted to a number.
Throws:
TypeError
- If argument is a Symbol or not coercible.
Param | Type | Description |
---|
argument | * | The argument to convert to a number. |
Example
import toNumber from 'to-number-x';
console.log(toNumber('1'));
console.log(toNumber(null));
console.log(toNumber(true));
console.log(toNumber('0o10'));
console.log(toNumber('0b10'));
console.log(toNumber('0xF'));
console.log(toNumber(' 1 '));
console.log(toNumber(Symbol('')));
console.log(toNumber(Object.create(null)));